package org.zfes.snowier.cloud.zbss.layer.tc.biz.controller;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.core.util.ZStrUtil;
import org.zfes.snowier.web.annos.ListParam;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.layer.tc.biz.model.Progress;
import org.zfes.snowier.cloud.zbss.layer.tc.biz.service.IProgressService;
@Controller 
@RequestMapping("/tcms/progress")
public class ProgressController extends BaseController {

	private String viewPathPrefix="/tcms";
	
	@Autowired
	private IProgressService progressService;
	
	@RequestMapping(value={"/",""}, method = RequestMethod.GET,produces = MediaType.TEXT_HTML_VALUE)
    public Object index(){
		return forward(viewPathPrefix,"progress.html");
    }
	
	//@RequiresPermissions(value="progress:loadProgressList",desc="案件进展列表")
    @RequestMapping(value="/loadProgressDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadProgressDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  progressService.loadProgressDataSet(params);
	    return dataSet;
    }
	
	//@RequiresPermissions(value="progress:addProgress",desc="案件进展添加")
    @RequestMapping(value="/addProgress", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object addProgress(Progress progress){
		progressService.createProgress(progress);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="progress:loadProgress",desc="案件进展加载")
    @RequestMapping(value="/loadProgress", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadProgress(Long id){
		Optional<Progress> ops = progressService.loadProgressById(id);
		return ajaxQuery("progress",ops);
    }
	
	//@RequiresPermissions(value="progress:updateProgress",desc="案件进展更新")
    @RequestMapping(value="/updateProgress", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateProgress(Progress progress){
		progressService.updateProgress(progress);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="progress:deletProgress",desc="案件进展删除")
    @RequestMapping(value="/deletProgress", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deletProgress(Long id){
		progressService.deletProgress(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }
    @RequestMapping(value="/setProgressEnabled", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object setProgressEnabled(@ListParam(Long.class)List<Long> ids,Boolean  enabled){
    	progressService.setEnabled(ids,enabled);
		return ajaxDoneSuccess("数据操作成功 ");
    }
}